package org.grottarossa.template.data;

import org.grottarossa.template.data.pojo.content.Content;
import org.grottarossa.template.data.pojo.discussions.Discussion;
import org.grottarossa.template.data.pojo.history.History;
import org.grottarossa.template.data.pojo.tasks.Task;
import org.grottarossa.template.data.pojo.users.User;

import com.thoughtworks.xstream.XStream;

public class Marshaler
{
	public static Marshaler marshaler;

	XStream xstream;//is thread safe

	private Marshaler()
	{
		xstream = new XStream();
		xstream.alias("content", Content.class);
		xstream.alias("task", Task.class);
		xstream.alias("discussion", Discussion.class);
		xstream.alias("history", History.class);
		xstream.alias("user", User.class);
	}

	public static Marshaler instance()
	{
		synchronized (Marshaler.class)
		{
			if ( marshaler == null)
			{
				marshaler = new Marshaler();
			}

		return marshaler;
		}
	}

	public XStream getXstream() {
		return xstream;
	}
	public void setXstream(XStream xstream) {
		this.xstream = xstream;
	}

}
